/**
 * @file       Label.cpp
 * @brief      TODO
 * @author     Huabo Zheng
 * @date       Jan 12, 2012
 * @Copyright  2012, www.netgear.com Inc. All rights reserved.
 */

#include "Label.h"
#include "errorcode.h"
#include "lcd/IDisplay.h"

namespace NS_LCD_AFW
{

CLabel::CLabel() :
		m_strText("")
{
	this->setFocusable(false);
	this->setHightlightable(false);
}

CLabel::~CLabel()
{
}

void CLabel::setText(std::string text)
{
	m_strText = text;
}

int CLabel::onDraw(IDisplay *pDisplay)
{
	int iRet = ERR_SUCCESS;
	if (NULL == pDisplay)
	{
		return ERR_NULL_POINTER;
	}

	if (!this->isVisible())
	{
		return ERR_OBJECT_UN_VISIBLE;
	}

	pDisplay->write(this->getPosition().getX(), this->getPosition().getY(),
			this->getRect().getWidth(), this->getRect().getHight(),
			m_strText.c_str());
	return iRet;
}

void CLabel::onSetFocus()
{
}

void CLabel::onLostFocus()
{
}

void CLabel::onHightlight()
{
}

void CLabel::onUnHightlight()
{
}

int CLabel::onRightKeyPress()
{
	return CFrame::onRightKeyPress();
}

int CLabel::onLeftKeyPress()
{
	return CFrame::onLeftKeyPress();
}

int CLabel::onUpKeyPress()
{
	return CFrame::onUpKeyPress();
}

int CLabel::onDownKeyPress()
{
	return CFrame::onDownKeyPress();
}

int CLabel::onCreate()
{
	this->setText(this->getName());
	return CFrame::onCreate();
}

int CLabel::onEnterKeyPress()
{
	return CFrame::onEnterKeyPress();
}

int CLabel::onEscKeyPress()
{
	return CFrame::onEscKeyPress();
}
} /* namespace NS_LCD_AFW */
